package com.admission.communicate;



import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import com.admission.model.Order;
import com.admission.util.FileUtils;

public class OrderBuilder {
	public static Order CreatOrder() throws Exception {
		String pathString = FileUtils.getProjectRoot()+"\\WEB-INF\\xml\\order.xml";
		SAXReader reader = new SAXReader();
		Document doc = reader.read(pathString); // 获取到xml文件
		Element rootElm = doc.getRootElement();
		Order order = new Order();
		order.setMerId(rootElm.element("MerId").getTextTrim());
		order.setOrdAmt(rootElm.element("OrdAmt").getTextTrim());
		order.setCuryId(rootElm.element("CuryId").getTextTrim());
		order.setVersion(rootElm.element("Version").getTextTrim());
		order.setBgRetUrl(rootElm.element("BgRetUrl").getTextTrim());
		order.setPageRetUrl(rootElm.element("PageRetUrl").getTextTrim());
		order.setOrdDesc(rootElm.element("OrdDesc").getTextTrim());
		order.setShareType(rootElm.element("ShareType").getTextTrim());
		order.setShareAccount(rootElm.element("ShareAccount").getTextTrim());
		order.setActionUrl(rootElm.element("actionUrl").getTextTrim());
		
		return order;
	}
	
	public static void main(String[] args) {
		try {
			Order temp = CreatOrder();			
			System.out.println(temp.getBgRetUrl()); 
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
